import requests
from requests_toolbelt import MultipartEncoder

from apps.seleuinms.utils.request_utils import get_headers, parse_response


def get_house_detail(collat_id, cookies):
    url = "http://22.230.57.12:8080/housePropertyInfo/getHousePropertyInfo"
    params = {
        'collatId': collat_id,
        'provCode': '3200',
        'deledFlag': '0',
    }
    m = MultipartEncoder(params)
    headers = get_headers(m.content_type)
    response = requests.post(url, data=m, headers=headers,
                             cookies=cookies)
    return parse_response(response)


def house_code(collat_id, cookies):
    """房屋产权证书"""
    url = 'http://22.230.57.12:8080/warrantInfo/queryWarrantInfoList'
    params = {
        'collatId': collat_id,
        'provCode': '3200',
        'deledFlag': '0',
    }
    m = MultipartEncoder(params)
    headers = get_headers(m.content_type)
    response = requests.post(url, data=m, headers=headers,
                             cookies=cookies)
    return parse_response(response)


def request3(url, params, cookies):
    m = MultipartEncoder(params)
    headers = get_headers(m.content_type)
    response = requests.post(url, data=m, headers=headers,
                             cookies=cookies)
    return parse_response(response)
